package com.example.springbootrabbitmq.backup_exchange.receive;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: RabbitMQ
 * @BelongsPackage: com.example.springbootrabbitmq.backup_exchange.receive
 * @Author: HUI
 * @CreateTime: 2022-04-14 19:26
 * @Description: 报警消费者，当无法投递的小新进入报警队列时接收
 */

@Component
@Slf4j
public class WarningConsumer {
    public static final String WARNING_QUEUE_NAME = "warning.queue";

    @RabbitListener(queues = WARNING_QUEUE_NAME)
    public void receiveWarningMsg(Message message) {
        String msg = new String(message.getBody());
        log.error("报警发现不可路由消息：{}", msg);
    }

}
